package coroutines

import kotlinx.coroutines.*

/**
 * 惰性
 */

fun main() {
    val one: Job =GlobalScope.launch(start = CoroutineStart.LAZY) {
        println("${getNow()},GlobalScope.launch")
    }
    val two :Deferred<Int> = GlobalScope.async(start =  CoroutineStart.LAZY){
        println("${getNow()},GlobalScope.async")
        14
    }
    runBlocking {
        delay(1000)
    }
    println("到目前为止，两个协程并没有运行，只是创建了出来。")
    one.start() //启动协程
    two.start()

    println("协程已经启动了")
    runBlocking {
        delay(1000)
    }
    println("main is cover.")
}